<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>商品添加</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
 <link rel="stylesheet" type="text/css" href="__APP__/statics/css/style.css" />
 
 <script type="text/javascript" charset="utf-8">window.UEDITOR_HOME_URL= "__PUBLIC__/ueditor/";</script>
 <script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/editor_config.js"></script>
 <script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/editor_all.js"></script>
 <script src="__APP__/statics/jquery-1.9.1.min.js" type="text/javascript"></script>
 <script type="text/javascript" src="__APP__/statics/jquery.form.js"></script>

<script type="text/javascript">
$(function(){
      $("[name=sop]").click(function(){
			var content=editor.getContent();
			$("[name=content]").val(content);
			$('#goods').ajaxSubmit({
					success:alert("添加成功")});// 提交表单
					return false;   //防止浏览器提交表单
	  }); //ajax提交表单
      //增加input
      $("#add_pic").click(function(){
	          $("<div id='nor_pic'>相册:<input type='file' name='goods_pic[]' size='20'><a href='javascript:;' name='del_pic'>移除</a></div>").appendTo($("#n_pic"));
			  delPic();
	  })
      
	  //移除按钮
	  function delPic() {
	      $("a[name=del_pic]").unbind().click(function () {
          $(this).parent().remove();
	  })
	  }
	  //检查货号是否重复
	  $("#goods_bn").blur(function(){
	     var bn=$("#goods_bn").val();
		 $.ajax({
		     type:"GET",
			 url:"__URL__/check_bn",
			 dataType:"html",
			 data:{goods_bn:bn},
			 success:function(data){
				                $("#check_bn").html(data);
								}
			 })
	  })

	  //获取规格
	  $("#choose_prop").click(function(){
	          var price=$("[name=goods_price]").val();
			  var store=$("[name=goods_store]").val();
	          var stra=[];
			  $("[name=prop_name]:checked").each(function(){
                     stra.push($(this).val()); 
               }); 

			   $.ajax({
			      type:"POST",
				  url:"__GROUP__/Goodsprop/prop_value",
				  dataType:"html",
				  data:{"goods_prop":stra,"price":price,"store":store},
				  success:function(data){$("#guige").html(data);}
				})
	  })

	  //ajax请求
      $("#goods_cat").change(function(){
	          var cat=$("#goods_cat").val();

			  $.ajax({
			      type:"POST",
				  url:"__GROUP__/Goodsmodel/get_model_value",
				  dataType:"html",
				  data:{goods_cat:cat},
				  success:function(data){$("#kuozhan").html(data);}
				})
			  })

});
</script>
<style type="text/css">
input{padding:5px}
#maintb{border:0;margin:0 auto;width:70%;border-style: dashed; border-width: 2px; padding-left: 4px; padding-right: 4px; padding-top: 1px; padding-bottom: 1px;border-color:#CCCCCC;}
#pictb{border:0 ;width:100%;border-collapse: collapse; border-style: solid; border-width: 2px; padding-left: 4px; padding-right: 4px; padding-top: 1px; padding-bottom: 1px;border-color:#CCCCCC;}
#pictb td{height:30px;}
#nor_pic{height:30px;}
</style>
</head>
<body>

<h2>商品添加</h2>
<hr>
<form id="goods" method="POST" action="__URL__/add" enctype="multipart/form-data">
<textarea type="text" name="content" style="display:none"></textarea>
	<table id="maintb">
		<tr>
			<td align="right" colspan="3">
			<p align="left"><b><font style="font-size: 20pt">基本信息</font></b></td>
		</tr>
		<tr>
			<td width="11%" align="right" bgcolor="#E2E8EB">商品分类：</td>
			<td width="55%"><select size="1" id="goods_cat" name="goods_cat">
			<option>-选择商品分类-</option>
<?php if(is_array($goods_cat)): $i = 0; $__LIST__ = $goods_cat;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$cat): $mod = ($i % 2 );++$i; if($cat["pid"] == 0): ?><option value="<?php echo ($cat["cat_id"]); ?>">【<?php echo ($cat["fullname"]); ?>】</option>
    <?php else: ?>
	        <option value="<?php echo ($cat["cat_id"]); ?>"><?php echo ($cat["fullname"]); ?></option><?php endif; endforeach; endif; else: echo "" ;endif; ?>
			</select></td>
			<td width="50%" rowspan="12" valign=top>
<!--商品图片start-->
			<table  id="pictb">
				<tr><td height="40"><b><font size="4">商品图片：</font></b></td></tr>
				<tr><td>封面:<input type="file" name="goods_pic[]" size="20"></td></tr>
				<tr><td><input type="button" value="再添加一张…" id="add_pic"></td></tr>
				<tr><td id="n_pic"></td></tr>
          </table>
<!--商品图片end-->
			</td>
		</tr>
		<tr>
			<td width="11%" align="right" bgcolor="#E2E8EB">所属店铺：</td>
			<td width="55%">
				<select name="shop_id">
					<option value="0">自营</option>
<?php if(is_array($shop_list)): $i = 0; $__LIST__ = $shop_list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$shop): $mod = ($i % 2 );++$i;?><option value="<?php echo ($shop["shop_id"]); ?>"><?php echo ($shop["shop_name"]); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
				</select>
				<font color="#FF0000" size="3">*</font>
			</td>
		</tr>
		<tr>
			<td width="11%" align="right" bgcolor="#E2E8EB">商品名称：</td>
			<td width="55%"><input type="text" name="goods_name" size="35"><font color="#FF0000" size="3">*</font></td>
		</tr>
		<tr>
			<td width="11%" align="right" bgcolor="#E2E8EB">商品品牌：</td>
			<td width="55%"><select size="1" name="goods_brand">
			<option value="">选择品牌</option>
<?php if(is_array($goods_brand)): $i = 0; $__LIST__ = $goods_brand;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$goods_brand): $mod = ($i % 2 );++$i;?><option value="<?php echo ($goods_brand["brand_id"]); ?>"><?php echo ($goods_brand["brand_name"]); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
			</select></td>
		</tr>
		<tr>
			<td width="11%" align="right" bgcolor="#E2E8EB">商品编号：</td>
			<td width="55%"><input type="text" id="goods_bn" name="goods_bn" size="20"><div id="check_bn"></div></td>
		</tr>
		<tr>
			<td width="11%" align="right" bgcolor="#E2E8EB">计量单位：</td>
			<td width="55%"><input type="text" name="goods_unit" size="20"></td>
		</tr>
		<tr>
			<td width="11%" align="right" bgcolor="#E2E8EB">简介：</td>
			<td width="55%"><textarea rows="5" name="s_intro" cols="31"></textarea></td>
		</tr>
		<tr>
			<td width="11%" align="right" bgcolor="#E2E8EB">是否上架：</td>
			<td width="55%"><input type="radio" value="0" name="is_post" checked>是 
			<input type="radio" value="1" name="is_post">否</td>
		</tr>
		<tr>
			<td width="11%" align="right" bgcolor="#E2E8EB">销售价：</td>
			<td width="55%"><input type="text" name="goods_price" size="20"></td>
		</tr>
		<tr>
			<td width="11%" align="right" bgcolor="#E2E8EB">成本价：</td>
			<td width="55%"><input type="text" name="goods_cost" size="20"></td>
		</tr>
		<tr>
			<td width="11%" align="right" bgcolor="#E2E8EB">市场价：</td>
			<td width="55%"><input type="text" name="mktprice" size="20"></td>
		</tr>
		<tr>
			<td width="11%" align="right" bgcolor="#E2E8EB">重量：</td>
			<td width="55%"><input type="text" name="goods_weight" size="20"></td>
		</tr>
		<tr>
			<td width="11%" align="right" bgcolor="#E2E8EB">库存：</td>
			<td width="55%"><input type="text" name="goods_store" size="20"></td>
		</tr>
		<tr>
			<td width="11%" align="right" bgcolor="#E2E8EB">货位：</td>
			<td width="55%"><select size="1" name="goods_place">
			<option value="">选择货位</option>
<?php if(is_array($goods_place)): $i = 0; $__LIST__ = $goods_place;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$goods_place): $mod = ($i % 2 );++$i;?><option value="<?php echo ($goods_place["place_id"]); ?>"><?php echo ($goods_place["fullname"]); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
			</select></td>
		</tr>
	</table>
	<br>
	<table id="maintb">
		<tr>
			<td><span style="font-size: 20pt"><b>扩展属性</b></span></td>
		</tr>
		<tr>
			<td><div id="kuozhan">请先选择商品分类……</div></td>
		</tr>
		</table>
	<br>
	<table id="maintb">
		<tr>
			<td><span style="font-size: 20pt"><b>商品规格</b></span></td>
		</tr>
		<tr>
			<td>
<?php if(is_array($goods_prop)): $i = 0; $__LIST__ = $goods_prop;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$goods_prop): $mod = ($i % 2 );++$i;?><input type="checkbox" id="prop_name" name="prop_name" value="<?php echo ($goods_prop["prop_name"]); ?>"><?php echo ($goods_prop["prop_name"]); endforeach; endif; else: echo "" ;endif; ?>
              <input type="button" id="choose_prop" value="生成所有商品">
			  如果不需要那么多留空即可
            </td>
		</tr>
		<tr>
			<td><div id="guige">请选择规格……</div></td>
		</tr>
		</table>
		
	<br>
	<table id="maintb">
		<tr>
			<td><span style="font-size: 20pt"><b>详细介绍</b></span></td>
		</tr>
		<tr>
			<td><textarea  id="contents" name="content"></textarea></td>
		</tr>
	</table>
	<br>
	<table id="maintb">
		<tr><td><span style="font-size: 20pt"><b>商品标签</b></span></td></tr>
		<tr>
			<td>
            <select name="goods_label">
			   <option value="">无</option>
			   <option value="hot">热卖</option>
			   <option value="price">特价</option>
			   <option value="rec">推荐</option>
		   </select>
		  </td>
		</tr>
	</table>


	<p align="center">
	<input type="submit" value="保存并添加新商品" id="send" style="padding:5px;width:200px;">
	<input type="button" value="保存并添加相似商品" name="sop" style="padding:5px;width:200px;">
	</p>
</form>
<br><br><br>

<link rel="stylesheet" type="text/css" href="__APP__/statics/css/jNotify.jquery.css" />
<script type="text/javascript" src="__APP__/statics/jNotify.jquery.js"></script>

</body>
<SCRIPT type="text/javascript">  
    var editor = new UE.ui.Editor();  
    editor.render("contents");  
</SCRIPT>
</html>